---
import type { IElement, MDXInstance, Post } from "@/types";
import { getLocaleTime } from "@/util";
export interface Props extends IElement {
	post: MDXInstance<Post>;
	withDesc?: boolean;
}

const { post, as: Element = "div", withDesc = false } = Astro.props as Props;
const { publishDate } = post.frontmatter;
const date = new Date(publishDate);
const datetime = date.toISOString();
const postDate = getLocaleTime(date, { month: "short" });
---

<time {datetime} class="min-w-[120px] text-gray-500">{postDate}</time>
<Element>
	<a href={post.url} class="inline-block cactus-link line-clamp-1">
		{post.frontmatter.title}
	</a>
</Element>
{
	withDesc && (
		<q class="block italic line-clamp-3">{post.frontmatter.description}</q>
	)
}
